/**
 * @param {number[]} nums
 * @return {number[]}
 */
var sortArrayByParityII = function(nums) {
  let temp = [[], []]
  nums.forEach(v => temp[v % 2].push(v))
  return nums.map((v, i) => temp[i % 2].pop())
};